import type { InjectionKey, ComputedRef } from 'vue';
import { createContext, useContext } from '/@/hooks/core/useContext';

export interface ComplexContextProps {
  parentParam: ComputedRef<string | undefined>;
  parentQuery: ComputedRef<string | undefined>;
  moduleId: string;
  isUpdate: boolean;
  preview: boolean;
  isChild: boolean;
  detail: boolean;
  record?: Indexable;
}

const key: InjectionKey<ComplexContextProps> = Symbol();

export function createComplexContext(context: ComplexContextProps) {
  return createContext<ComplexContextProps>(context, key, { native: true });
}

export function useComplexContext() {
  return useContext<ComplexContextProps>(key);
}
